# Create your models here.

# -*- coding:utf-8 -*-
import uuid

from django.db import models
from Apps.common.custommodel import ModifyModel, CustomModel

TYPE_CHOICES = (
    (1, '文本相关'),
    (2, '人物相关'),
    (3, '电话相关'),
    (4, '身份证相关'),
    (5, '档案相关'),
    (6, '地址相关'),
    (7, '坐标相关'),
    (8, '公司相关'),
    (9, '汽车相关'),
    (10, '银行相关'),
    (11, '图书相关'),
    (12, '条形码相关'),
    (13, '颜色相关'),
    (14, '信用卡相关'),
    (15, '货币相关'),
    (16, '时间相关'),
    (17, '职务相关'),
    (18, 'python相关'),
    (19, '网路相关'),
    (20, '用户代理相关'),
    (21, '文件相关'),
    (22, '编码文件相关'),
)


class DataGenerationCat(ModifyModel):
    """
    分类表
    """
    name = models.CharField(max_length=50, default="", verbose_name="分类名称", null=True, blank=True)
    index = models.IntegerField(default=0, verbose_name="排序", null=True, blank=True)

    class Meta:
        db_table = "datagenerationcat"
        verbose_name = "datagenerationcat"
        ordering = ('index', '-create_time',)

    def __str__(self):
        return self.name


class DataGeneration(ModifyModel):
    """
    数据生成表
    """
    name = models.CharField(max_length=50, default="", verbose_name="数据类型名称", null=True, blank=True)
    value = models.CharField(max_length=50, default="", verbose_name="数据类型值", null=True, blank=True)
    category = models.ManyToManyField(to=DataGenerationCat, db_constraint=False, verbose_name="数据类型的分类",)
    index = models.IntegerField(default=0, verbose_name="排序", null=True, blank=True)
    args = models.JSONField(default=dict, verbose_name="JSON参数数据", null=True, blank=True)
    description = models.TextField(default="", verbose_name="数据类型描述", null=True, blank=True)
    isEnable = models.BooleanField(default=True, verbose_name="是否可用")
    isDelete = models.BooleanField(default=False, verbose_name="是否删除")
    isDownload = models.BooleanField(default=False, verbose_name="是否可下载，用于下载时，不能同时生成多个")
    isNoArgs = models.BooleanField(default=False, verbose_name="是否用于直接生成数据，生成csv、XML、xlsx、xls、时选择字段时使用")

    class Meta:
        db_table = "datageneration"
        verbose_name = "datageneration"
        ordering = ('index', '-create_time',)

    def __str__(self):
        return self.name
